package com.liveinstars.post.business.service.impl;

import com.liveinstars.post.business.handler.theme.config.support.Group;
import com.liveinstars.post.business.handler.theme.config.support.ThemeProperty;
import com.liveinstars.post.business.model.support.ThemeFile;
import com.liveinstars.post.business.repository.ThemeSettingRepository;
import com.liveinstars.post.business.service.OptionService;
import com.liveinstars.post.business.service.ThemeService;
import com.onepiece.cache.service.CacheService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.lang.Nullable;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;
import java.nio.file.Path;
import java.util.List;
import java.util.Optional;

/**
 * Theme service implementation.
 *
 * @author ryanwang
 * @date 2019-03-26
 */
@Slf4j
@Service
public class ThemeServiceImpl implements ThemeService {

    /**
     * Theme work directory.
     */
    private final OptionService optionService;

    private final CacheService cacheStore;

    private final ApplicationEventPublisher eventPublisher;

    private final ThemeSettingRepository themeSettingRepository;

    /**
     * Activated theme id.
     */
    @Nullable
    private volatile String activatedThemeId;

    /**
     * Activated theme property.
     */
    private volatile ThemeProperty activatedTheme;

    public ThemeServiceImpl(
                            OptionService optionService,
                            CacheService cacheStore,
                            ApplicationEventPublisher eventPublisher,
                            ThemeSettingRepository themeSettingRepository) {
        this.optionService = optionService;
        this.cacheStore = cacheStore;
        this.eventPublisher = eventPublisher;
        this.themeSettingRepository = themeSettingRepository;
    }


    @Override
    public ThemeProperty getThemeOfNonNullBy(String themeId) {
        return null;
    }

    @Override
    public Optional<ThemeProperty> fetchThemePropertyBy(String themeId) {
        return Optional.empty();
    }

    @Override
    public List<ThemeProperty> getThemes() {
        return null;
    }

    @Override
    public List<ThemeFile> listThemeFolderBy(String themeId) {
        return null;
    }

    @Override
    public List<String> listCustomTemplates(String themeId) {
        return null;
    }

    @Override
    public List<String> listCustomTemplates(String themeId, String prefix) {
        return null;
    }

    @Override
    public boolean templateExists(String template) {
        return false;
    }

    @Override
    public boolean themeExists(String themeId) {
        return false;
    }

    @Override
    public Path getBasePath() {
        return null;
    }

    @Override
    public String getTemplateContent(String absolutePath) {
        return null;
    }

    @Override
    public String getTemplateContent(String themeId, String absolutePath) {
        return null;
    }

    @Override
    public void saveTemplateContent(String absolutePath, String content) {

    }

    @Override
    public void saveTemplateContent(String themeId, String absolutePath, String content) {

    }

    @Override
    public void deleteTheme(String themeId, Boolean deleteSettings) {

    }

    @Override
    public List<Group> fetchConfig(String themeId) {
        return null;
    }

    @Override
    public String render(String pageName) {
        return null;
    }

    @Override
    public String renderWithSuffix(String pageName) {
        return null;
    }

    @Override
    public String getActivatedThemeId() {
        return null;
    }

    @Override
    public ThemeProperty getActivatedTheme() {
        return null;
    }

    @Override
    public Optional<ThemeProperty> fetchActivatedTheme() {
        return Optional.empty();
    }

    @Override
    public ThemeProperty activateTheme(String themeId) {
        return null;
    }

    @Override
    public ThemeProperty upload(MultipartFile file) {
        return null;
    }

    @Override
    public ThemeProperty add(Path themeTmpPath) throws IOException {
        return null;
    }

    @Override
    public ThemeProperty fetch(String uri) {
        return null;
    }

    @Override
    public ThemeProperty fetchLatestRelease(String uri) {
        return null;
    }

    @Override
    public List<ThemeProperty> fetchBranches(String uri) {
        return null;
    }

    @Override
    public List<ThemeProperty> fetchReleases(String uri) {
        return null;
    }

    @Override
    public ThemeProperty fetchRelease(String uri, String tagName) {
        return null;
    }

    @Override
    public ThemeProperty fetchBranch(String uri, String branchName) {
        return null;
    }

    @Override
    public void reload() {

    }

    @Override
    public ThemeProperty update(String themeId) {
        return null;
    }

    @Override
    public ThemeProperty update(String themeId, MultipartFile file) {
        return null;
    }
}
